﻿package 
{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.text.TextField;
	import flash.ui.*;
	
	
	public class Main extends MovieClip{
		
		var loader:Loader = new Loader();
		var infoText:TextField = new TextField();
		var eventProc:EventProc=new EventProc(stage as Object); 
		var line:Shape=new Shape();

		
		public function Main():void{
			
			
			infoText.name="infoText";
			infoText.background=true;
			infoText.backgroundColor=0xEEEEEE;
			infoText.width=150;
			addChild(infoText);
			
			var request:URLRequest = new URLRequest("lib/Walk.swf");
			loader.load(request);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteProc);
			
			
		}
		
		function loadCompleteProc(e:Event){ 
			addChild(loader.content as MovieClip);
			Player.player=(loader.content as MovieClip);
			
			line.graphics.lineStyle(2, 0x000000, 1);
			line.graphics.moveTo(0,232);
			line.graphics.lineTo(600,232);
			addChild(line);
			
			trace("main this:"+this.numChildren);
			trace("main stage:"+stage.numChildren);
			trace("main root:"+(root as Object).numChildren);

			
			infoText.text="现有对象数:"+numChildren+"\n";
			for(var i=0;i<numChildren;i++)
			{
				infoText.appendText("对象"+i+":");
				infoText.appendText((getChildAt(i) as Object).constructor );
				infoText.appendText("\n");
			}
			
			(getChildAt(1) as MovieClip).x=250;
			(getChildAt(1) as MovieClip).y=200;
			(getChildAt(1) as MovieClip).gotoAndStop(4);
			
		}
	}
		
}